//
//  String+Extension.swift
//  SwiftStory
//
//  Created by ZxjMacBookPro on 2020/4/25.
//  Copyright © 2020 ZxjMacBookPro. All rights reserved.
//

import Foundation

extension String{
    ///缓存路径
    func cachesDir() -> String {

        let path = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).last!
        let name = (self as NSString).lastPathComponent
        let filePath = (path as NSString).appendingPathComponent(name)
        
        return filePath
    }
    
    ///文档路径
    func doctDir() -> String {
        let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).last!
        let name = (self as NSString).lastPathComponent
        let filePath = (path as NSString).appendingPathComponent(name)

        return filePath
    }
    
    ///临时路径
    func tmpDir() -> String {
        let path = NSTemporaryDirectory()
        let name = (self as NSString).lastPathComponent
        let filePath = (path as NSString).appendingPathComponent(name)

        return filePath
    }
}
